<template>
	<view class="bg" :class="title != '' ? 'bg-color' : ''">
		
		<u-icon @click="goBack" size="36" name="arrow-left"></u-icon>
		<text>{{title}}</text>
		<view class="">
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				required: "特需挂号",
			},
			url:{
				type:String,
				required: "",
			}

		},
		onLoad(query) {
			// query 是一个对象，包含页面跳转过程中传递的参数
			console.log('参数:', query);
		},
		watch: {
			title(newTitle) {
				this.title = newTitle
			},
		},
		methods: {
			goBack() {
				
				const pages = getCurrentPages();
				console.log(pages.length,"444444")
				if (pages.length === 1) {
				    // 用户在第一页时，返回首页
				    uni.switchTab({
				      url: '/pages/index/index'
				    })
				} else {
				    uni.navigateBack({
				    	delta: 1,
				    });
				}
				
				
				
			}
		}
	}
</script>

<style lang="less" scoped>
	.bg {
		width: 100%;
		height: 120rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 24rpx;
		padding-top: 65rpx;


		.title-img {
			width: 100rpx;
		}

		text {
			display: inline-block;

			color: #1a1a1a;
			font-size: 32rpx;
			font-weight: bold;
		}

		view {
			width: 100rpx;
		}
	}

	.bg-color {
		// background: #fff;
	}
</style>